<template>
  <div>
    <pt-search :params="params" :config="config" label-width="110px" @search="search"/>
    <pt-table
      :params="params"
      :columns="columns"
      :dataSource="tableData"
      :options="options"
      :fetch="getTableList"
      :pagination="pagination"
    />
  </div>
</template>

<script>
import * as api from "@/api/company";
export default {
  data() {
    return {
      columns: [
        // 表单配置
        { prop: "agentName", label: "区域",  minWidth: 140, align: "left"},
        { 
          label: "微信转账", minWidth: 100, align: "center",
          render: row => {
            return <div>{row.wxTran ? '已设置' : '未设置' }</div>;
          }
         },
        { 
          label: "微信公众号", minWidth: 100, align: "center",
          render: row => {
            return <div>{row.wxPub ? '已设置' : '未设置' }</div>;
          }
        },
        { 
          label: "微信小程序", minWidth: 100, align: "center",
          render: row => {
            return <div>{row.wxMini ? '已设置' : '未设置' }</div>;
          }
        },
        { 
          label: "微信开放支付", minWidth: 100, align: "center",
          render: row => {
            return <div>{row.wxOpen ? '已设置' : '未设置' }</div>;
          }
        },
        { 
          label: "支付宝支付", minWidth: 100, align: "center",
          render: row => {
            return <div>{row.zfb ? '已设置' : '未设置' }</div>;
          }
        },
        { button: true, label: "操作", width: 60,
          group: [
            { name: "查看", type: "text", onClick: row => this.handleClick(row.id, row.agentId) }
          ]
        }
      ],
      pagination: { total: 0, page: 0, size: 10, curPage: 1 }, // 分页
      options: { // 表单外观
        mutiSelect: false, //  多选则 mutiSelect
        index: false, // 显示序号
        loading: false, // 表格动画
        initTable: true // 是否一挂载就加载数据
      },
      tableData: [], //表单数据
      config: [
        { key: "agentIds", type: "agentList", label: "区域" }
      ],
      params: {
        page: 0,
        size: 10,
        agentIds: [] //区域
      }
    }
  },
  methods: {
    search() { // 搜索
      this.pagination.curPage = 1
      this.pagination.page = 0
      this.getTableList()
    },
    handleClick(id, agentId) { //查看/修改订单操作
      this.$router.push({
        path: '/main/company/paySet',
        query: { id, agentId }
      })
    },
    getTableList() { // 获取订单数据
      this.options.loading = true
      const params = { ...this.params }
      params.page = this.pagination.page
      params.size = this.pagination.size
      params.agentIds = params.agentIds.length > 0 ? params.agentIds.join(",") : ""
      api.payInfoList(params).then(res => {
        if (res.success) {
          this.tableData = res.data.list
          this.pagination.total = res.data.total
        }
      }).finally(() => {
        this.options.loading = false
      })
    }
  }
};
</script>

<style scoped>

</style>
